package myapps.ttclient.activity.connection;

import myapps.ttclient.app.TTClientApplication;
import myapps.ttclient.connection.ConnectionListManager;
import myapps.ttclient.connection.Connection_Wifi;
import myapps.ttclient.R;
import android.os.Bundle;
import android.widget.EditText;

public class ConnectionEditActivity_Wifi extends ConnectionEditActivity
{
	private TTClientApplication application;
	private ConnectionListManager connectionListManager;

	private Connection_Wifi connection;

	private EditText host;
	private EditText port;

	@Override
	protected void onCreate(Bundle savedInstanceState) {
		this.application = (TTClientApplication) this.getApplication();

		this.connectionListManager = this.application.getConnectionListManager();

		this.setContentView(R.layout.connectionwifiedit);

		super.onCreate(savedInstanceState);

		this.connection = (Connection_Wifi) connectionParam;

		this.host = (EditText) this.findViewById(R.id.host);
		this.port = (EditText) this.findViewById(R.id.port);

		getCommonIntentContent();
	}

	@Override
	protected void onResume() {
		super.onResume();

		this.host.setText(this.connection.getHost());
		this.port.setText(Integer.toString(this.connection.getPort()));
	}

	@Override
	protected void onPause() {
		super.onPause();
	}

	@Override
	public void onSave() {
		this.connection.setHost(this.host.getText().toString());
		this.connection.setPort(Integer.parseInt(this.port.getText().toString()));

		super.onSave();

		if(type == TYPE_NEW) {
			this.connectionListManager.getConnectionList_Wifi().add(this.connection);
		}
	}
}